<?php
/**
 * PatientSignalUpload1 model class file.
 *
 * @package   models
 * @since     1.0
 * @filesource
 */

/**
 * The first form in patient signal upload. Contains basic personal information.
 * 
 * PatientSignalUpload1 is a Form class. 
 * It is the data structure for keeping form data.
 */
class PatientSignalUpload1 extends CFormModel{

	/**
	 * @var string
	 */
	public $subject;
	/**
	 * @var string
	 */
	public $dateOfBirth;
	/**
	 * @var integer
	 */
	public $ageYear;
	/**
	 * @var integer
	 */
	public $ageMonth;
	/**
	 * @var integer
	 */
	public $gender;
	/**
	 * @var integer
	 */
	public $disorderId;
	/**
	 * @var string
	 */
	public $severity;
	/**
	 * @var string
	 */
	public $recordingTime;
	/**
	 * @var string
	 */
	public $pastDiagnosticHistory;
	
	/**
	 * Declares the validation rules.
	 * The rules will be used when requesting validation by call self.validate().
	 * Many class method will call self.validate(), eg: CActiveRecord.save().
	 * @return array validation rules for model attributes.
	 * @see PatientSignal
	 */
	public function rules()
	{
		return array(
			// duplicate the mentioned attributes in PatientSignal
			array('subject, ageYear, ageMonth, gender, recordingTime, disorderId, dateOfBirth', 'required','on'=>'next'),
			array('ageYear, ageMonth, gender, disorderId', 'numerical', 'integerOnly'=>true),
			// subject name noly allow letters, digits, underscores and dash line.
			array('subject', 'match', 'pattern'=>'/^[0-9a-zA-z_\-]+$/','message'=>'{attribute} is invalid. Must be letters and digits only.'),		
			array('subject, severity', 'length', 'max'=>255),	
			array('dateOfBirth, pastDiagnosticHistory', 'safe'),
		);
	}

	/**
	 * Returns the labels for each column variables.
	 * This will be used to render label on page.
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'subject' => 'Subject Identifier',
			'disorderId'=>'Disorder',
		);
	}
}
